package domain;

    //HTTP Exceptions worden hier verwerkt.

import java.util.HashMap;
import java.util.Map;


    /**
     * This class contains a HashMap of HTTP response codes.
     * @author HTTPDragon Team
     */
    class HTTPException extends RuntimeException{
    //declaratie mogelijke responseCodes
        private String currentException = null;
        // RFC2616 used as partial source 
        // (HTTP/1.1 response codes) @ http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html
    private Map<Integer, String> responseCodes = new HashMap<>();
    {responseCodes.put(100,"Continue");
    responseCodes.put(101,"Switching Protocols");
    responseCodes.put(200,"OK");
    responseCodes.put(201,"Created");
    responseCodes.put(202,"Accepted");
    responseCodes.put(203,"Non-Authorative Information");
    responseCodes.put(204,"No Content");
    responseCodes.put(205,"Reset Content");
    responseCodes.put(206,"Partial Content");
    responseCodes.put(300,"Multiple Choices");
    responseCodes.put(301,"Moved Permanently");
    responseCodes.put(302,"Found");
    responseCodes.put(303,"See Other");
    responseCodes.put(304,"Not Modified");
    responseCodes.put(305,"Use Proxy");
    responseCodes.put(307,"Temporary Redirect");
    responseCodes.put(324,"Empty Response" );
    responseCodes.put(400,"Bad Request");
    responseCodes.put(401,"Unauthorized");
    responseCodes.put(402,"Payment Required");
    responseCodes.put(403,"Forbidden");
    responseCodes.put(404,"Not Found");
    responseCodes.put(405,"Method Not Allowed");
    responseCodes.put(406,"Not Acceptable");
    responseCodes.put(407,"Proxy Authentication Required");
    responseCodes.put(408,"Request Time-out");
    responseCodes.put(409,"Conflict");
    responseCodes.put(410,"Gone");
    responseCodes.put(411,"Length Required");
    responseCodes.put(412,"Precondition Failed");
    responseCodes.put(413,"Request Entity Too Large");
    responseCodes.put(414,"Request-URI Too Large");
    responseCodes.put(415,"Unsupported Media Type");
    responseCodes.put(416,"Requested range not satisfiable");
    responseCodes.put(417,"Expectation Failed");
    responseCodes.put(418,"I'm a teapot"); //RFC 2324 - http://datatracker.ietf.org/doc/rfc2324/?include_text=1  
    responseCodes.put(500,"Internal Server Error");
    responseCodes.put(501,"Not Implemented");
    responseCodes.put(502,"Bad Gateway");
    responseCodes.put(503,"Service Unavailable");
    responseCodes.put(504,"Gateway Time-out");
    responseCodes.put(505,"HTTP Version not supported");}

    /**
     * Public constructor for HTTPException.
     * @param responseCode the current response code.
     */
        public HTTPException (int responseCode){
           setResponse(responseCode);
        }
        
        private void setResponse(int responsecode){
            currentException =  responsecode + ": " + responseCodes.get(responsecode);
        }
        /**
         * Returns a response code's description.
         * @return Response code description.
         */
    @Override
        public String getMessage(){
            return currentException;
        }
    }